package com.example.blogserver.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.blogserver.a_utils.ResponseBodyMessage;
import com.example.blogserver.service.SensitiveWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @description
 * @descriptionDetail
 * @Author B3300
 * @copyright 摸鱼王胖嘟嘟
 * @Date 2024/3/28 14:36
 */
@RestController
@RequestMapping("/word")
public class SensitiveWordController {

    @Autowired
    private SensitiveWordService sensitiveWordService;

    @GetMapping("/page")
    public ResponseBodyMessage<Page> page(int page, int pageSize) {
        return sensitiveWordService.page(page, pageSize);
    }

    @RequestMapping("/add")
    public ResponseBodyMessage<String> insertSensitiveWord(HttpServletRequest request,
                                                           @RequestParam("word") String word) {
        return sensitiveWordService.insertSensitiveWord(request, word);
    }

    @RequestMapping("/update")
    public ResponseBodyMessage<String> updateSensitiveWord(HttpServletRequest request,
                                                           @RequestParam("word") String word,
                                                           @RequestParam("updateNewWord") String updateNewWord) {
        return sensitiveWordService.updateSensitiveWord(request, word, updateNewWord);
    }

    @RequestMapping("/delete")
    public ResponseBodyMessage<String> deleteSensitiveWord(HttpServletRequest request,
                                                           @RequestParam("word") String word) {
        return sensitiveWordService.deleteSensitiveWord(request, word);
    }
}
